/* This is a template command. */
CmdUtils.CreateCommand({
  name: "add-command",
  icon: "chrome://ubiquity/skin/icons/favicon.ico",
  author: {name: "David Ockey"},
  license: "GPL",
  description: "Add new ubiquity commands using a URL.",
  help: "Use 'page' to select the current page. <br />Or enter the url.",
  takes: {"input": /.*/},
  preview: function(pblock, input) {
     var block;
     var doc = Application.activeWindow.activeTab.document;
     
     if (input.text.match(/^page$/)) {
        block = doc.location.href;
     }
     else {
        block = input.text;
     }
     pblock.innerHTML = block;
  },
  execute: function(input) {
     var block;
     var doc = Application.activeWindow.activeTab.document;
     
     if (input.text.match(/^page$/)) {
        block = encodeURI(doc.location.href);
     }
     else {
        block = encodeURI(input.text);
     }
     var exec = "chrome://ubiquity/content/confirm-add-command.html?url=" + block;
     exec    += "&sourceUrl=" + block;
     var title = window.prompt("Please enter a title for the feed:");
     exec    += "&title=" + encodeURI(title);
     doc.location.href = exec; 
  }
});
